<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <script src="/static/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layui/others/dtree/dtree.css">
    <link rel="stylesheet" href="/static/layui/others/dtree/font/dtreefont.css">
    <title>各供电单位设备状态平均停留时间</title>
    <!--yc-->
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>各供电单位计量设备状态平均停留时间</legend>
</fieldset>
<div class="layui-collapse">
    <div class="layui-colla-item" >
        <h2 class="layui-colla-title layui-elem-quote">设备参数搜索</h2>
        <div class="layui-colla-content layui-show">
            <form class="layui-form" action="" id="searchForm">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">供电单位</label>
                        <div class="layui-input-inline" style="z-index:998; width:500px;">
                            <ul id="iframeTree2" class="dtree" data-id="00"></ul>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">时间范围</label>
                        <div class="layui-input-inline">
                            <select name="sjfw" id="sjfw" lay-verify="required">
                                <option value=1 selected>今年内</option>
                                <option value=2>1年内</option>
                                <option value=3>2-4年</option>
                                <option value=4>5-7年</option>
                                <option value=5>8年以上</option>
                                <option value=6>全部</option>
                            </select>
                        </div>
                    </div>
                    <!--<div class="layui-inline">-->
                        <!--<label class="layui-form-label">设备状态</label>-->
                        <!--<div class="layui-input-inline">-->
                            <!--<select name="sbztdm"  id="sbztdm" lay-search="true">-->
                                <!--<option value="" selected>请选择</option>-->
                                <!--<option value="10">购入/预建档</option>-->
                                <!--<option value="11">退货</option>-->
                                <!--<option value="20">待检</option>-->
                                <!--<option value="21">换货</option>-->
                                <!--<option value="30">检定</option>-->
                                <!--<option value="35">合格在货</option>-->
                                <!--<option value="39">待领</option>-->
                                <!--<option value="40">待装</option>-->
                                <!--<option value="50">运行</option>-->
                                <!--<option value="60">拆回</option>-->
                                <!--<option value="61">归还</option>-->
                                <!--<option value="66">待检定</option>-->
                                <!--<option value="67">鉴定</option>-->
                                <!--<option value="68">返厂维修</option>-->
                                <!--<option value="70">淘汰</option>-->
                                <!--<option value="75">待报废</option>-->
                                <!--<option value="80">报废</option>-->
                                <!--<option value="90">遗失</option>-->
                            <!--</select>-->
                        <!--</div>-->
                    <!--</div>-->
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">设备类别</label>
                        <div class="layui-input-inline">
                            <select name="sblbdm" id="sblbdm" lay-verify="required" lay-search="true" lay-filter="sblbFilter">
                                <option value="" selected>请选择</option>
                                <option value="01">电能表</option>
                                <option value="02">互感器</option>
                                <option value="03">负荷管理终端</option>
                                <option value="04">配变监测计量终端</option>
                                <option value="05">集中器</option>
                                <option value="06">采集器</option>
                                <option value="07">厂站电能量采集终端</option>
                                <option value="08">售电管理装置</option>
                                <option value="09">计量封印</option>
                                <option value="10">计量表箱</option>
                                <option value="11">计量柜</option>
                                <option value="12">SIM卡</option>
                                <option value="13">电能计量标准装置</option>
                                <option value="14">电能计量标准器</option>
                                <option value="15">配套设备</option>
                                <option value="16">测试设备</option>
                                <option value="17">型式试验设备</option>
                                <option value="18">其他装置</option>
                                <option value="19">电能表检测设备</option>
                                <option value="20">其它检测设备</option>
                                <option value="23">互感器检测设备</option>
                            </select>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">设备类型</label>
                            <div class="layui-input-inline">
                                <select name="sblxdm" id="sblxdm" lay-search="true"></select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="button" onclick="doSearch();" class="layui-btn layui-btn-sm">搜索</button>
                            <button type="reset" class="layui-btn layui-btn-sm">重置</button>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <!--<div class="layui-inline">-->
                        <!--<label class="layui-form-label">设备型号</label>-->
                        <!--<div class="layui-input-inline">-->
                            <!--<input type="text" name="sbxhdm" id="sbxhdm" autocomplete="on" class="layui-input">-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--<div class="layui-inline">-->
                        <!--<label class="layui-form-label" style="width:67px">到货批次号</label>-->
                        <!--<div class="layui-input-inline">-->
                            <!--<input type="text" name="dhpch" id="dhpch" autocomplete="on" class="layui-input">-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--<div class="layui-inline">-->
                        <!--<label class="layui-form-label">资产编号</label>-->
                        <!--<div class="layui-input-inline">-->
                            <!--<input type="text" name="zcbh" id="zcbh" autocomplete="on" class="layui-input">-->
                        <!--</div>-->
                    <!--</div>-->
                </div>
            </form>
        </div>
    </div>

    <div class="layui-colla-item">
        <h2 class="layui-colla-title layui-elem-quote ">平均停留时间(分)</h2>
        <div class="layui-colla-content layui-show">
            <table class="layui-hide" id="test" lay-filter="test"></table>
        </div>
    </div>

    <div class="layui-colla-item">
        <h2 class="layui-colla-title layui-elem-quote">设备数量统计(台)</h2>
        <div class="layui-colla-content layui-show">
            <table class="layui-hide" id="devTotal" lay-filter="devTotal"></table>
        </div>
    </div>
</div>

<script th:inline="javascript">
    var $, element, layer, dtree, table, laydate;
    var panlongQuID="0501",numberTotal=1000000,levelTreeCode=1;//常量
    layui.extend({
        dtree: '{/}/static/layui/others/dtree/dtree'   // {/}的意思即代表采用自有路径，即不跟随 base 路径
    }).use(['dtree', 'layer', 'jquery', 'element', 'table', 'laydate'], function () {
        table = layui.table;
        $ = layui.jquery;
        element = layui.element;
        layer = layui.layer;
        dtree = layui.dtree;
        laydate = layui.laydate;
        //日期
        laydate.render({
            elem: '#kssj'
            ,type: 'month'
            ,range: '~'
            ,theme: 'grid'
        });
        //表1
        table.render({
            elem: '#test'
            , url: "/devices/dnbStateStayTab"
            , title: '设备时间表'
            , toolbar: '#toolbarDemo'
            , totalRow: true
//            , defaultToolbar:['filter']
            , parseData: function (res) { //res 即为原始返回的数据
                var list=res;
                return { //参考response的定义
                    "code": 0, //解析接口状态
                    "msg": "success", //解析提示文本
                    "total": numberTotal, //解析数据长度
                    "rows": list //解析数据列表
                };
            }
            ,cols: [[
                {type: 'numbers', fixed: 'left', rowspan: 2}
                ,{field:'gddwbm', title:'供电单位', width:230, rowspan: 2, fixed: 'left'}
                ,{field:"gr", title:"购入/预建档", width:120, rowspan: 2, sort: true}
                ,{field:"th", title:"退货", width:120, rowspan: 2, sort: true}
                ,{field:"dj", title:"待检", width:120, rowspan: 2, sort: true}
                ,{field:"hh", title:"换货", width:120, rowspan: 2, sort: true}
                ,{field:"j3d", title:"检定", width:120, rowspan: 2, sort: true}
                ,{field:"hgzk", title:"合格在库", width:120, rowspan: 2, sort: true}
                ,{field:"dl", title:"待领", width:120, rowspan: 2, sort: true}
                ,{field:"dz", title:"待装", width:120, rowspan: 2, sort: true}
                ,{field:"yx", title:"运行", width:120, rowspan: 2, sort: true}
                ,{field:"ch", title:"拆回", width:120, rowspan: 2, sort: true}
                ,{field:"gh", title:"归还", width:120, rowspan: 2, sort: true}
                ,{field:"gjd", title:"待检定", width:120, rowspan: 2, sort: true}
                ,{field:"jd", title:"鉴定", width:120, rowspan: 2, sort: true}
                ,{field:"fcwx", title:"返厂维修", width:120, rowspan: 2, sort: true}
                ,{field:"tt", title:"淘汰", width:120, rowspan: 2, sort: true}
                ,{field:"dbf", title:"待报废", width:120, rowspan: 2, sort: true}
                ,{field:"bf", title:"报废", width:120, rowspan: 2, sort: true}
                ,{field:"ys", title:"遗失", width:120, rowspan: 2, sort: true}
            ]]
            ,response: {
                statusName: 'code' //规定数据状态的字段名称，默认：code
                ,statusCode: 0 //规定成功的状态码，默认：0
                ,msgName: 'msg' //规定状态信息的字段名称，默认：msg
                ,countName: 'total' //规定数据总数的字段名称，默认：count
                ,dataName: 'rows' //规定数据列表的字段名称，默认：data
            }
            ,where: {key:2 , gddwbm:panlongQuID}
            ,even: true
            ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                //,curr: 5 //设定初始在第 5 页
                ,groups: 6
                ,prev: "上一页"
                ,next: "下一页"
                ,first: "首页" //不显示首页
                , last: false //不显示尾页
                , limit: 10
                , limits: [10, 30, 50, 100, 150]
            }
            , text: {
                none: '无数据..'
            }
            ,id:'devicesTable'
        });
        //表
        table.render({
            elem: '#devTotal'
            , url: "/devices/dnbStateStayTab"
            , toolbar: '#toolbarDemo'
            , title: '设备数据统计'
            , totalRow: true
//            , defaultToolbar:['filter']
            , parseData: function (res) { //res 即为原始返回的数据
                var list=res;
                return { //参考response的定义
                    "code": 0, //解析接口状态
                    "msg": "yc", //解析提示文本
                    "total": numberTotal, //解析数据长度
                    "rows": list //解析数据列表
                };
            }
            ,cols: [[
                {type: 'numbers', fixed: 'left', rowspan: 2}
                ,{field:'gddwbm', title:'供电单位', width:180, rowspan: 2, fixed: 'left'}
                ,{field:"gr", title:"购入/预建档", width:120, rowspan: 2, sort: true}
                ,{field:"th", title:"退货", width:120, rowspan: 2, sort: true}
                ,{field:"dj", title:"待检", width:120, rowspan: 2, sort: true}
                ,{field:"hh", title:"换货", width:120, rowspan: 2, sort: true}
                ,{field:"j3d", title:"检定", width:120, rowspan: 2, sort: true}
                ,{field:"hgzk", title:"合格在库", width:120, rowspan: 2, sort: true}
                ,{field:"dl", title:"待领", width:120, rowspan: 2, sort: true}
                ,{field:"dz", title:"待装", width:120, rowspan: 2, sort: true}
                ,{field:"yx", title:"运行", width:120, rowspan: 2, sort: true}
                ,{field:"ch", title:"拆回", width:120, rowspan: 2, sort: true}
                ,{field:"gh", title:"归还", width:120, rowspan: 2, sort: true}
                ,{field:"gjd", title:"待检定", width:120, rowspan: 2, sort: true}
                ,{field:"jd", title:"鉴定", width:120, rowspan: 2, sort: true}
                ,{field:"fcwx", title:"返厂维修", width:120, rowspan: 2, sort: true}
                ,{field:"tt", title:"淘汰", width:120, rowspan: 2, sort: true}
                ,{field:"dbf", title:"待报废", width:120, rowspan: 2, sort: true}
                ,{field:"bf", title:"报废", width:120, rowspan: 2, sort: true}
                ,{field:"ys", title:"遗失", width:120, rowspan: 2, sort: true}
            ]]
            ,response: {
                statusName: 'code' //规定数据状态的字段名称，默认：code
                ,statusCode: 0 //规定成功的状态码，默认：0
                ,msgName: 'msg' //规定状态信息的字段名称，默认：msg
                ,countName: 'total' //规定数据总数的字段名称，默认：count
                ,dataName: 'rows' //规定数据列表的字段名称，默认：data
            }
            ,where: {key:3 , gddwbm:panlongQuID}
            ,even: true
            ,page: {
                layout: ['limit', 'prev', 'page', 'next', 'skip']
                ,groups: 6
                ,prev: "上一页"
                ,next: "下一页"
                ,first: "首页"
                , last: false
                , limit: 10
                , limits: [10, 30, 50, 100, 150]
            }
            , text: {
                none: '无数据..'
            }
            ,id:'devTotalTable'
        });

        //关于树的一切
        var iframeTree2=dtree.render({
            elem: "#iframeTree2",
            data: [[${devRegion}]],
            dataStyle: "layuiStyle",  //使用layui风格的数据格式
            dataFormat: "list",  //配置data的风格为list
            response:{message:"total",statusName:"total",statusCode:"200",rootName:'rows',
                treeId:"id",parentId:"p_id",title:"name"},  //修改response中返回数据的定义
            record: true, //开启数据记录模式
            method: "GET",
            initLevel: 2,
            select: true, //指定下拉树模式
            width :"100%",
            icon: "-1",  // 隐藏二级图标
            selectTips: "请选择",
            selectInputName: {
                leaf: "leaf", //是否叶子节点
                level: "level", //层级
                nodeId: "gddwbm"
            },
            selectInitVal: panlongQuID
        });
        // 绑定节点的单击事件
        dtree.on("node('iframeTree2')", function(obj){
//            layer.tips(obj.param.recordData.code, this, {tips: [4, '#646464']});
            layer.tips(obj.param.nodeId, this, {tips: [4, '#646464']});
            // 当前节点为最后一级节点时触发事件
            if (obj.param.leaf || obj.param.level>=levelTreeCode) {
                console.log('最后一级节点');
            }else{
                layer.msg("请选择三级树以下的供电单位,否则无效！");
            }
        });
        $("body").on("click", function(event){
            $("div[dtree-id][dtree-select]").removeClass("layui-form-selected");
            $("div[dtree-id][dtree-card]").removeClass("dtree-select-show layui-anim layui-anim-upbit");
        });
        //级联显示--------
        layui.form.on('select(sblbFilter)', function (data) {
            if (data.value == "01") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("单相感应式长寿命电能表", "0111001"));
                $('#sblxdm').append(new Option("单相感应式电能表", "0111002"));
                $('#sblxdm').append(new Option("RS-485接口单相电子式电能表", "0112010"));
                $('#sblxdm').append(new Option("单相载波电子式电能表", "0112020"));
                $('#sblxdm').append(new Option("单相电子式电能表(费控)", "0112030"));
                $('#sblxdm').append(new Option("单相复费率电能表", "1"));
                $('#sblxdm').append(new Option("单相智能电能表（费控）", "0113000"));
                $('#sblxdm').append(new Option("三相感应式长寿命电能表", "0131001"));
                $('#sblxdm').append(new Option("三相感应式电能表", "0131002"));
                $('#sblxdm').append(new Option("普通三相电子式电能表", "0132000"));
                $('#sblxdm').append(new Option("三相载波电子式电能表", "0132020"));
                $('#sblxdm').append(new Option("三相多功能电能表", "0133000"));
                $('#sblxdm').append(new Option("三相多功能电能表(费控)", "0133030"));
                $('#sblxdm').append(new Option("0.2级三相多功能电能表", "0133040"));
                $('#sblxdm').append(new Option("三相多功能电能表(进口)", "0133100"));
                $('#sblxdm').append(new Option("0.2级三相多功能电能表(进口)", "0133140"));
                $('#sblxdm').append(new Option("三相数字式电能表", "0134000"));
                $('#sblxdm').append(new Option("三相智能电能表（费控）", "0135000"));
                $('#sblxdm').append(new Option("数字化电能表", "0136000"));
            } else if (data.value == "02") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("电流互感器", "0211000"));
                $('#sblxdm').append(new Option("电压互感器", "0212000"));
                $('#sblxdm').append(new Option("组合式互感器", "0233000"));
            } else if (data.value == "03") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("负荷管理终端", "0330000"));
            } else if (data.value == "04") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("配变监测计量终端", "0430000"));
            } else if (data.value == "05") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("集中抄表系统集中器", "0530000"));
                $('#sblxdm').append(new Option("Ⅱ型集中器", "0540000"));
            } else if (data.value == "06") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("集中抄表系统采集器", "0610000"));
                $('#sblxdm').append(new Option("Ⅱ型采集器", "0620000"));
            } else if (data.value == "07") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("机架式厂站终端", "0731000"));
                $('#sblxdm').append(new Option("壁挂式厂站终端", "0732000"));
            } else if (data.value == "08") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("售电管理装置", "0800000"));
            } else if (data.value == "09") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("计量封印", "0900000"));
                $('#sblxdm').append(new Option("二维码防伪计量封印", "0901000"));
                $('#sblxdm').append(new Option("RFID防伪计量封印", "0902000"));
                $('#sblxdm').append(new Option("带芯片卡扣式封印", "0903000"));
                $('#sblxdm').append(new Option("卡扣式封印", "0904000"));
            } else if (data.value == "10") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("单相计量表箱（PC外壳）", "1011002"));
                $('#sblxdm').append(new Option("单相计量表箱（SMC外壳）", "1011003"));
                $('#sblxdm').append(new Option("单相计量表箱（镀锌钢板）", "1011004"));
                $('#sblxdm').append(new Option("单相计量表箱（不锈钢）", "1011005"));
                $('#sblxdm').append(new Option("10kV低压计量表箱（不锈钢外壳）", "1031001"));
                $('#sblxdm').append(new Option("三相计量表箱（PC外壳）", "1031002"));
                $('#sblxdm').append(new Option("三相计量表箱（SMC外壳）", "1031003"));
                $('#sblxdm').append(new Option("三相计量表箱（镀锌钢板）", "1031004"));
                $('#sblxdm').append(new Option("三相计量表箱（不锈钢）", "1031005"));
                $('#sblxdm').append(new Option("10kV高压计量表箱（不锈钢外壳）", "1032001"));
                $('#sblxdm').append(new Option("单相费控计量表箱", "1041001"));
                $('#sblxdm').append(new Option("三相费控计量表箱", "1041002"));
            } else if (data.value == "11") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("固定式低压电能计量柜", "1131001"));
                $('#sblxdm').append(new Option("移开式低压电能计量柜", "1131002"));
                $('#sblxdm').append(new Option("固定式高压电能计量柜", "1132001"));
                $('#sblxdm').append(new Option("移开式高压电能计量柜", "1132002"));
            } else if (data.value == "12") {
                $('#sblxdm').html('<option value="">请选择</option>');
            } else if (data.value == "13") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("单相电能表标准装置", "1310110"));
                $('#sblxdm').append(new Option("三相电能表标准装置", "1330110"));
                $('#sblxdm').append(new Option("电流互感器标准装置", "1330210"));
                $('#sblxdm').append(new Option("电压互感器标准装置", "1330220"));
                $('#sblxdm').append(new Option("互感器标准装置", "1330230"));
            } else if (data.value == "14") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("单相标准电能表", "1410110"));
                $('#sblxdm').append(new Option("三相标准电能表", "1430120"));
                $('#sblxdm').append(new Option("标准电流互感器", "1430210"));
                $('#sblxdm').append(new Option("标准电压互感器", "1430220"));
            } else if (data.value == "15") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("单相电能表检定装置", "1510110"));
                $('#sblxdm').append(new Option("三相电能表检定装置", "1530110"));
                $('#sblxdm').append(new Option("电流互感器检定装置", "1530210"));
                $('#sblxdm').append(new Option("电压互感器检定装置", "1530220"));
                $('#sblxdm').append(new Option("互感器校验仪", "1530230"));
                $('#sblxdm').append(new Option("互感器检定装置", "1530240"));
                $('#sblxdm').append(new Option("终端检测台体", "1530310"));
                $('#sblxdm').append(new Option("电流负载箱（配套设备）", "1530410"));
                $('#sblxdm').append(new Option("电压负载箱（配套设备）", "1530420"));
                $('#sblxdm').append(new Option("耐压测试仪(配套设备)", "1530510"));
                $('#sblxdm').append(new Option("升流器(配套设备)", "1530520"));
                $('#sblxdm').append(new Option("升压器(配套设备)", "1530530"));
                $('#sblxdm').append(new Option("时钟测试仪", "1530610"));
                $('#sblxdm').append(new Option("功耗测试仪", "1530620"));
            } else if (data.value == "16") {
                $('#sblxdm').html('<option value="">请选择</option>');

                $('#sblxdm').append(new Option("升流器（测试设备）", "1600020"));
                $('#sblxdm').append(new Option("升压器（测试设备）", "1600030"));
                $('#sblxdm').append(new Option("单相电能表现场校验仪", "1610110"));
                $('#sblxdm').append(new Option("三相电能表现场校验仪", "1630110"));
                $('#sblxdm').append(new Option("互感器现场校验仪", "1630200"));
                $('#sblxdm').append(new Option("二次导线压降现场测试仪", "1630201"));
                $('#sblxdm').append(new Option("二次实际负载现场测试仪", "1630202"));
                $('#sblxdm').append(new Option("电流负载箱（测试设备）", "1630301"));
                $('#sblxdm').append(new Option("电压负载箱（测试设备）", "1630302"));
                $('#sblxdm').append(new Option("耐压测试仪（测试设备）", "1630401"));
                $('#sblxdm').append(new Option("变压器线路参数测试仪", "1630402"));
                $('#sblxdm').append(new Option("局部放电测试仪", "1630403"));
                $('#sblxdm').append(new Option("负载箱检定装置", "1630501"));
                $('#sblxdm').append(new Option("校验仪检定装置", "1630502"));
            } else if (data.value == "17") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("静电放电试验设备", "1730101"));
                $('#sblxdm').append(new Option("射频电磁场辐射试验设备", "1730102"));
                $('#sblxdm').append(new Option("电快速脉冲群试验设备", "1730103"));
                $('#sblxdm').append(new Option("浪涌（冲击）试验设备", "1730104"));
                $('#sblxdm').append(new Option("工频磁场试验设备", "1730105"));
                $('#sblxdm').append(new Option("电压跌落试验设备", "1730106"));
                $('#sblxdm').append(new Option("振铃波试验设备", "1730107"));
                $('#sblxdm').append(new Option("高低温试验设备", "1730108"));
                $('#sblxdm').append(new Option("谐波试验设备", "1730109"));
                $('#sblxdm').append(new Option("衰减震荡波试验设备", "1730110"));
                $('#sblxdm').append(new Option("冲击电压试验设备", "1730111"));
                $('#sblxdm').append(new Option("砂尘试验设备", "1730112"));
                $('#sblxdm').append(new Option("淋雨试验设备", "1730113"));
                $('#sblxdm').append(new Option("氙灯老化试验设备", "1730114"));
                $('#sblxdm').append(new Option("弹簧冲击设备", "1730115"));
                $('#sblxdm').append(new Option("灼热丝试验设备", "1730116"));
                $('#sblxdm').append(new Option("冲击试验设备", "1730117"));
                $('#sblxdm').append(new Option("振动试验设备", "1730118"));
                $('#sblxdm').append(new Option("大功率脉冲过流试验设备", "1730119"));
                $('#sblxdm').append(new Option("智能电能表软件比对装置", "1730120"));
                $('#sblxdm').append(new Option("EMC试验装置", "1730121"));
                $('#sblxdm').append(new Option("盐雾试验箱", "1730122"));
                $('#sblxdm').append(new Option("紫外试验箱", "1730123"));
                $('#sblxdm').append(new Option("燃弧试验箱", "1730124"));
                $('#sblxdm').append(new Option("低压断路器", "1730125"));
            } else if (data.value == "18") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("终端检测装置", "1830101"));
                $('#sblxdm').append(new Option("耐压试验装置", "1830201"));
            } else if (data.value == "19") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("单相标准电能表", "1930001"));
                $('#sblxdm').append(new Option("单相电能表检定装置", "1930002"));
                $('#sblxdm').append(new Option("单相电能表现场校验仪", "1930003"));
                $('#sblxdm').append(new Option("三相电能表检定装置", "1930004"));
                $('#sblxdm').append(new Option("三相电能表现场校验仪", "1930005"));
                $('#sblxdm').append(new Option("数字式电能表现场测试仪", "1930006"));
                $('#sblxdm').append(new Option("电能表走字试验台", "1930007"));
                $('#sblxdm').append(new Option("电能表耐压试验装置", "1930008"));
                $('#sblxdm').append(new Option("单相电能表自动化检定流水线", "1930009"));
                $('#sblxdm').append(new Option("三相电能表自动化检定流水线", "1930011"));
                $('#sblxdm').append(new Option("三相标准电能表", "1930012"));
            } else if (data.value == "20") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("试验变压器", "1930021"));
                $('#sblxdm').append(new Option("升流器", "1930022"));
                $('#sblxdm').append(new Option("`升压器", "1930023"));
                $('#sblxdm').append(new Option("调压器", "1930024"));
                $('#sblxdm').append(new Option("互感器检定装置", "1930025"));
                $('#sblxdm').append(new Option("互感器耐压试验装置", "1930026"));
                $('#sblxdm').append(new Option("互感器校验仪检定装置", "1930027"));
                $('#sblxdm').append(new Option("电压互感器二次压降测试仪", "1930028"));
                $('#sblxdm').append(new Option("互感器二次负载测试仪", "1930029"));
                $('#sblxdm').append(new Option("低压电流互感器自动化检定流水线", "1930030"));
                $('#sblxdm').append(new Option("谐振升压器", "1930031"));
                $('#sblxdm').append(new Option("电压互感器负载箱", "1930032"));
                $('#sblxdm').append(new Option("电流互感器负载箱", "1930033"));
                $('#sblxdm').append(new Option("负载箱校准装置", "1930034"));
                $('#sblxdm').append(new Option("电流互感器带电测试仪", "1930035"));
                $('#sblxdm').append(new Option("电压互感器分析仪", "1930036"));
                $('#sblxdm').append(new Option("CT变比快速校验仪", "1930037"));
                $('#sblxdm').append(new Option("10kV计量互感器自动化检定流水线", "1930038"));
                $('#sblxdm').append(new Option("互感器校验仪", "1930039"));
                $('#sblxdm').append(new Option("标准电压互感器", "1930040"));
                $('#sblxdm').append(new Option("标准电流互感器", "1930041"));
            } else if (data.value == "23") {
                $('#sblxdm').html('<option value="">请选择</option>');
                $('#sblxdm').append(new Option("电能表通信协议测试装置", "1930051"));
                $('#sblxdm').append(new Option("计量自动化终端测试装置", "1930052"));
                $('#sblxdm').append(new Option("电磁兼容设备", "1930053"));
                $('#sblxdm').append(new Option("环境试验设备", "1930054"));
                $('#sblxdm').append(new Option("温湿度记录仪", "1930055"));
                $('#sblxdm').append(new Option("机械性能试验设备", "1930056"));
                $('#sblxdm').append(new Option("绝缘电阻测试仪", "1930057"));
                $('#sblxdm').append(new Option("局部放电测试仪", "1930058"));
                $('#sblxdm').append(new Option("导纳测试仪", "1930059"));
                $('#sblxdm').append(new Option("高压计量故障分析仪", "1930060"));
                $('#sblxdm').append(new Option("变压器容量测试仪", "1930061"));
                $('#sblxdm').append(new Option("高低压变比测试仪", "1930062"));
                $('#sblxdm').append(new Option("电能质量分析仪", "1930063"));
                $('#sblxdm').append(new Option("大电阻绝缘电阻表", "1930064"));
                $('#sblxdm').append(new Option("电能表回收装置", "1930065"));
                $('#sblxdm').append(new Option("计量自动化终端自动化检定流水线", "1930066"));
                $('#sblxdm').append(new Option("10kV计量互感器自动化检定流水线", "1930067"));
                $('#sblxdm').append(new Option("自动抽检系统", "1930068"));
                $('#sblxdm').append(new Option("通信性能检测装置", "1930069"));
            }else if (data.value == "") {
                $('#sblxdm').html('');
            }
            layui.form.render("select");
        });

    });

    function doSearch() {  //搜索
        //通过jquery获取参数
        var leaf, level, sbztdm, sblbdm, sblxdm, zcbh, dhpch, sbxhdm, gddwbm,sjfw, data = $("#searchForm").serializeArray(),dateList=[];
        for (var i = 0; i < data.length; i++) {
            switch (data[i].name) {
                case "leaf":
                    leaf = data[i].value;
                    break;
                case "level":
                    level = data[i].value;
                    break;
                case "sbztdm":
                    sbztdm = data[i].value;
                    break;
                case "sblbdm":
                    sblbdm = data[i].value;
                    break;
                case "sblxdm":
                    sblxdm = data[i].value;
                    break;
                case "zcbh":
                    zcbh = data[i].value;
                    break;
                case "dhpch":
                    dhpch = data[i].value;
                    break;
                case "sbxhdm":
                    sbxhdm=data[i].value;
                    break;
                case "gddwbm":
                    gddwbm=data[i].value;
                    break;
                case "sjfw":
                    sjfw=data[i].value;
                    break;
            }
        }

        dateList=timeHandle(sjfw);
        //默认x级树
        if(leaf=="true" || level>=levelTreeCode){
            layer.load(2, {time: 999});
            //table.reaload方法,附加上搜索条件
                table.reload('devicesTable', {
                    where:{
//                        sbztdm: sbztdm,
                        sblbdm: sblbdm,
                        sblxdm: sblxdm,
//                        zcbh: zcbh,
//                        dhpch: dhpch,
//                        sbxhdm: sbxhdm,
                        dateList: dateList,
                        gddwbm: gddwbm
                    },page:{
                        curr: 1
                    }
                });
                table.reload('devTotalTable', {
                    where:{
//                        sbztdm: sbztdm,
                        sblbdm: sblbdm,
                        sblxdm: sblxdm,
//                        zcbh: zcbh,
//                        dhpch: dhpch,
//                        sbxhdm: sbxhdm,
                        dateList: dateList,
                        gddwbm: gddwbm
                    },page:{
                        curr: 1
                    }
                });
        }else{
            layer.msg("请选择三级以下的供电单位！");
        }
    }
    //处理数据
    function dataHandle(data) {
        var dataList=[];
        for(k in data){
            data[k]["gddwbm"]=k;
            dataList.push(data[k]);
        }
        return dataList;
    }
    //处理时间
    function timeHandle(action) {
        var startDate,endDate,currDate=new Date(), list=[];
        var initStartDate=new Date(),initEndDate=new Date();
        switch(action){
            case "1":
                return null;
            case "2":
                initStartDate.setFullYear(initStartDate.getFullYear()-1);
                startDate=formatDateYmd(initStartDate);
                endDate=formatDateYmd(currDate);
                list.push(startDate);
                list.push(endDate);
                break;
            case "3":
                initStartDate.setFullYear(initStartDate.getFullYear()-4);
                initEndDate.setFullYear(initEndDate.getFullYear()-2);
                startDate=formatDateYmd(initStartDate);
                endDate=formatDateYmd(initEndDate);
                list.push(startDate);
                list.push(endDate);
                break;
            case "4":
                initStartDate.setFullYear(initStartDate.getFullYear()-7);
                initEndDate.setFullYear(initEndDate.getFullYear()-5);
                startDate=formatDateYmd(initStartDate);
                endDate=formatDateYmd(initEndDate);
                list.push(startDate);
                list.push(endDate);
                break;
            case "5":
                initStartDate.setFullYear(initStartDate.getFullYear() - 100);
                initEndDate.setFullYear(initEndDate.getFullYear() - 8);
                startDate = formatDateYmd(initStartDate);
                endDate = formatDateYmd(initEndDate);
                list.push(startDate);
                list.push(endDate);
                break;
            case "6":
                list.push('');
                list.push('');
                break;
        }
        return list;
    }

    /**
     *  js方法返回值：2021-06-08
     * @param date
     * @returns {string}
     */
    function formatDateYmd(date){
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? '0' + m : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        return y + '-' + m + '-' + d;
    }
</script>


</body>
</html>